Cytosim  PI
Cytoskeleton Simulator
FieldBase< VAL > Class Template Reference

Detailed Description

template<typename VAL>
class FieldBase< VAL >

The field is build on a Grid with square cells, because diffusion/reaction are then easier to implement. The Grid does not necessarily match the edges of the Space exactly, but instead extends outside, such as to cover the Space::inside entirely.

Each cell holds the amount of molecules. The local concentration can be obtained by dividing by the cell volume:

concentration = FieldGrid::cell(position) / FieldGrid::cellVolume();
Inheritance diagram for FieldBase< VAL >:
Grid< DIM, VAL, unsigned int > Object Node Inventoried Movable

Public Types

typedef Grid< DIM, VAL, unsigned int > FieldGrid
 the type of Grid from which the Field is derived
 
- Public Types inherited from Grid< DIM, VAL, unsigned int >
typedef VAL cell_type
 The type of cells (=CELL)
 
typedef unsigned int index_type
 the type for indices (=INDEX)
 

Public Member Functions

 FieldBase (FieldProp const *p)
 constructor
 
 ~FieldBase ()
 destructor
 
void setField ()
 initialize with squares of size 'step'
 
bool hasField () const
 true if field was set
 
real cellWidth () const
 size of cell
 
void setConcentration (real conc)
 set all cells to value = volume * conc
 
real sumValues ()
 total value
 
void step (FiberSet &, real)
 simulation step
 
void prepare ()
 initialize diffusion matrix (only for FieldScalar)
 
Tag tag () const
 return unique character identifying the class
 
const Propertyproperty () const
 return index of 'prop' in corresponding PropertyList
 
void write (OutputWrapper &out) const
 write Field to file using VAL::write() More...
 
void read_data (InputWrapper &in, Simul &)
 read Field from file using VAL::read()
 
void read (InputWrapper &in, Simul &sim)
 read Field and checks that the Grid::step has not changed
 
template<>
void prepare ()
 
template<>
void step (FiberSet &, real time_step)
 
template<>
void prepare ()
 
template<>
void step (FiberSet &, real)
 
- Public Member Functions inherited from Grid< DIM, VAL, unsigned int >
 Grid ()
 constructor
 
void destroy ()
 Free memory.
 
virtual ~Grid ()
 Destructor.
 
bool periodic ()
 true if boundary conditions are periodic
 
void periodic (const bool p)
 change boundary conditions
 
void setDimensions (const real infs[ORD], real sups[ORD], const int nbcells[ORD])
 set the sizes of the real space dimensions
 
bool hasDimensions ()
 true if setDimensions() was called
 
unsigned int nbCells () const
 total number of cells in the map
 
unsigned int nbCells (int d) const
 number of cells in dimensionality d
 
unsigned int dim () const
 
unsigned int dim (int d) const
 
const realinf () const
 position of the inferior (left/bottom/etc) edge
 
real inf (int d) const
 
const realsup () const
 position of the superior (right/top/etc) edge
 
real sup (int d) const
 
const realdelta () const
 the widths of a cell
 
real delta (int d) const
 
const realcellWidth () const
 
real cellWidth (int d) const
 
real position (int d, real c) const
 
real cellVolume () const
 the volume of a cell
 
real diagonalLength () const
 the length of the diagonal of a cell = sqrt( sum(cWidth[d]^2) )
 
real minimumWidth (unsigned int min_size) const
 the smallest cell width, along dimensions that have more than min_size cells
 
bool inside (const int coord[ORD]) const
 checks if coordinates are inside the box
 
bool inside (const real w[ORD]) const
 checks if point is inside the box
 
void bringInside (int coord[ORD]) const
 periodic image
 
void setCoordinatesFromIndex (int coord[ORD], unsigned intindx) const
 conversion from index to coordinates
 
void setCoordinatesFromPosition (int coord[ORD], const real w[ORD], const real offset=0) const
 conversion from Position to coordinates (offset should be in [0,1])
 
void setPositionFromIndex (real w[ORD], unsigned intindx, real offset=0) const
 conversion from Index to Position (offset should be in [0,1])
 
void setPositionFromCoordinates (real w[ORD], const int coord[ORD], real offset=0) const
 conversion from Coordinates to Position (offset should be in [0,1])
 
unsigned int indexFromCoordinates (const int coord[ORD]) const
 conversion from coordinates to index
 
unsigned int index (const real w[ORD], const real offset=0) const
 returns the index of the cell whose center is closest to the point w[]
 
void createCells ()
 allocate the array of cells
 
bool hasCells () const
 returns true if cells have been allocated
 
void deleteCells ()
 deallocate array of cells
 
void clear ()
 call function clear() for all cells
 
VAL * cell_addr ()
 address of the cell array ( equivalent to &cell(0) )
 
VAL & cell (const unsigned intindx) const
 return cell at index 'indx'
 
VAL & cell (const real w[ORD]) const
 reference to CELL whose center is closest to w[]
 
VAL & cell (const int c[ORD]) const
 reference to CELL of coordinates c[]
 
VAL & operator[] (const unsigned intindx) const
 operator access to a cell by index
 
VAL & operator() (const real w[ORD]) const
 operator access to a cell by position
 
VAL & operator() (const int c[ORD]) const
 short-hand access to a cell by co-oordinates
 
void create1D (real min, real max, int nbcells)
 create a 1D-map
 
VAL & cell1D (const int x) const
 access to cell for ORD==1
 
VAL & cell2D (const int x, const int y) const
 access to cell for ORD==2
 
VAL & cell3D (const int x, const int y, const int z) const
 access to cell for ORD==3
 
void createSquareRegions (const real radius)
 create regions which contains cells at a distance 'range' or less More...
 
void createRoundRegions (const real radius)
 create regions which contains cells at a distance 'range' or less More...
 
void createSideRegions (const int radius)
 regions that only contain cells of greater index. More...
 
bool hasRegions () const
 true is createRegions() or createRoundRegions() was called
 
int getRegion (int *&offsets, const unsigned intindx) const
 set region array 'offsets' for cell index More...
 
void deleteRegions ()
 free memory occupied by the regions
 
VAL interpolate (const real w[ORD]) const
 return linear interpolation of values stored at the center of each cell
 
VAL interpolate2D (const real w[ORD]) const
 return linear interpolation of values stored at the center of each cell, but only if ORD==2
 
VAL interpolate3D (const real w[ORD]) const
 return linear interpolation of values stored at the center of each cell, but only if ORD==3
 
void setValues (const VALval)
 set all cells to zero, if CELL supports this operation
 
void scaleValues (const VALval)
 set all cells to zero, if CELL supports this operation
 
VAL sumValues () const
 sum of all values, if CELL supports the addition
 
VAL maxValue () const
 maximum value over all cells
 
VAL minValue () const
 minimum value over all cells
 
bool hasNegativeValue () const
 true if any( cells[] < 0 )
 
VAL sumValuesInRegion (const unsigned intindx) const
 the sum of the values in the region around cell referred by 'indx'
 
VAL avgValueInRegion (const unsigned intindx) const
 the sum of the values in the region around cell referred by 'indx'
 
VAL maxValueInRegion (const unsigned intindx) const
 the maximum of the values in the region around cell referred by 'indx'
 
void printValues (FILE *file, const real offset) const
 write values to a file, with the position for each cell (file can be stdout)
 
void printValuesWithRange (FILE *file) const
 write values to a file, with the range for each cell (file can be stdout)
 
- Public Member Functions inherited from Object
 Object ()
 constructor
 
std::string reference () const
 concatenation of [ tag(), property()->index(), number() ] in plain ascii More...
 
void writeReference (OutputWrapper &) const
 write a reference that identifies the Object uniquely More...
 
void writeReference (OutputWrapper &, Tag tag) const
 write a reference, but using the provided Tag More...
 
int mark () const
 birth mark value
 
void mark (int m)
 set birth mark
 
int fleck () const
 fleck value (not stored in trajectory files)
 
void fleck (int f) const
 set fleck (the value is not stored in trajectory files)
 
Objectnext () const
 extends Node::next(), with a cast to preserve type
 
Objectprev () const
 extends Node::prev(), with a cast to preserve type
 
- Public Member Functions inherited from Node
 Node ()
 constructor set as unlinked
 
virtual ~Node ()
 destructor More...
 
bool linked () const
 true if Node is linked
 
Nodenext () const
 the next Node in the list, or zero if this is last
 
Nodeprev () const
 the previous Node in the list, or zero if this is first
 
NodeListlist () const
 the list where the object is linked, or zero
 
ObjectSetobjset () const
 return associated ObjectSet
 
- Public Member Functions inherited from Inventoried
 Inventoried ()
 initialize (name=0)
 
 ~Inventoried ()
 destructor
 
void number (Number n)
 change the serial number
 
Number number () const
 serial number : a integer identifier, unique within each class
 
- Public Member Functions inherited from Movable
 Movable ()
 constructor
 
virtual ~Movable ()
 destructor
 
virtual Vector position () const
 return the position in space of the object
 
virtual void setPosition (Vector const &)
 move object to specified position More...
 
virtual bool translatable () const
 true if object accepts translations (default=false)
 
virtual void translate (Vector const &)
 move the object ( position += given vector ) More...
 
virtual bool rotatable () const
 true if object accepts rotations (default=false)
 
virtual void rotate (Rotation const &)
 rotate the object around the origin of coordinates More...
 
virtual void rotateP (Rotation const &)
 rotate the object around its current position More...
 
virtual void foldPosition (Modulo const *)
 perform modulo for periodic boundary conditions More...
 

Public Attributes

FieldProp const * prop
 property
 

Static Public Attributes

static const Tag TAG = 'i'
 a unique character identifying the class
 
- Static Public Attributes inherited from Object
static const Tag TAG = 'v'
 Object::TAG = 'v' represents the 'void' pointer.
 

Additional Inherited Members

- Static Public Member Functions inherited from Grid< DIM, VAL, unsigned int >
static int ffloor (real x)
 a fast floor function
 
- Static Public Member Functions inherited from Object
static std::string strReference (char, int, Number, int)
 build a string reference by concatenating (tag, property_index, number, mark) More...
 
static void readReference (InputWrapper &, int &, Number &, int &, char pretag)
 read a reference (property_index, number, mark) from input More...
 
static void writeNullReference (OutputWrapper &)
 write a reference that does not refer to any Object
 
- Static Public Member Functions inherited from Movable
static Vector readPrimitive (std::istream &, const Space *)
 read a position specified with primitives, such as 'circle 5', etc. More...
 
static Vector readPosition (std::istream &, const Space *)
 read a position in space More...
 
static Vector readDirection (std::istream &, const Vector &, const Space *)
 read an orientation, and return a normalized vector More...
 
static Rotation readRotation (std::istream &, const Vector &, const Space *)
 read a rotation specified in is, at position pos More...
 
- Protected Attributes inherited from Grid< DIM, VAL, unsigned int >
VAL * gCell
 The array of pointers to cells.
 
unsigned int nCells
 The number of cells in the map; size of cells[].
 
unsigned int gDim [ORD]
 The number of cells in each dimension of the real space.
 
real gInf [ORD]
 The position of the inferior edge (min) in each dimension.
 
real gSup [ORD]
 The position of the superior edge (max) in each dimension.
 
real cWidth [ORD]
 cWidth[d] = ( gSup[d] - inf[d] ) / gDim[d]
 
real cDelta [ORD]
 cDelta[d] = 1.0 / cWidth[d]
 
real cVolume
 The volume occupied by one cell.
 
- Protected Attributes inherited from Node
NodenNext
 the next Node in the list
 
NodenPrev
 the previous Node in the list
 
- Protected Attributes inherited from Inventoried
Number nNumber
 object identifier, unique within the class defined by tag()
 

Member Function Documentation

void step ( FiberSet ,
real  time_step 
)
Todo:
implement Crank-Nicholson for diffusion
void write ( OutputWrapper out) const
inlinevirtual

Some of this should be moved to Grid

Implements Object.